<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
   <head>
      <base href="<%=basePath%>">
      <title>欢迎会员</title>
      <%@include file="../commons/induct.jsp"%>
      <link rel="stylesheet" href="${ctx }/css/radius.css" type="text/css"></link>
	  <link rel="stylesheet" href="${ctx }/css/table.css" type="text/css"></link>
	  <link rel="stylesheet" href="${ctx }/css/changebutton.css" type="text/css"></link>
   </head>
   <body lang="zh-cn">
   	 <div class="wrapper">	
   	 	<div class="main-container">
			<div align="center">
				<c:choose>
					<c:when test="${member.nickName != null && member.nickName != '' }">
						<div class="alert alert-danger">您好！${member.nickName }</div>
					</c:when>
					<c:otherwise>
						<div class="alert alert-danger">您好！${member.mobile }</div>
					</c:otherwise>
				</c:choose>
		   </div>
		   
		   <div align="center">
		   		<c:if test="${fn:length(accounts) > 0}"> 
			    	<div class="btn-group dropdown">
				  		<button type="button" style="border-radius:10px !important;"
				  			class="btn btn-default btn-sm dropdown-toggle thischange" data-toggle="dropdown">
				  			&nbsp;&nbsp;请&nbsp;&nbsp;选&nbsp;&nbsp;择&nbsp;&nbsp;企&nbsp;&nbsp;业&nbsp;&nbsp;
				 		 	<span class="icon-hand-up"></span>
				  		</button>
				  		<ul class="dropdown-menu" role="menu" id="qyId">
					  		<c:forEach items="${accounts }" var="account">
			   		  			<li value="${account.id}" <c:if test="${account.id == member.eaId }">id='bianzhifu'</c:if>>
			   				 		<a class="bianzhi">${account.name }</a>
			   					</li>
			   		  		</c:forEach>
				  		</ul>
					</div>
				</c:if>
		   </div>
		   <br />
		   <input type="hidden" id="memberId" value="${member.id }">
		   <div class="row" align="center">
		   		<a class="btn btn-app btn-success" id="btn-success"
               		href="wumimember/memberaction!initManager?member.id=${member.id }&member.eaId=${member.eaId }">
					<i class="icon-refresh bigger-230"></i>个人信息
				</a>
				<a class="btn btn-app btn-warning" id="btn-warning"
               		href="wumimember/logscoreaction!watchLogScoreDetail?member.id=${member.id }&member.eaId=${member.eaId }">
					<i class="icon-refresh bigger-230"></i>积分查询
				</a>
		   </div>
           <div class="row" align="center">
				<a class="btn btn-app btn-primary" id="btn-primary"
					href="wumimember/logconsumeaction!watchLogConsumeDetail?member.id=${member.id }&member.eaId=${member.eaId }">
					<i class="icon-refresh bigger-230"></i>消费记录
			  	</a>
			  	<a class="btn btn-app btn-danger" id="btn-danger"
					href="wumimember/logbalanceaction!watchLogBalanceDetail?member.id=${member.id }&member.eaId=${member.eaId }">
					<i class="icon-refresh bigger-230"></i>充值记录
			  	</a>
		   </div>
           <div class="row" align="center">
			  	<a class="btn btn-app btn-pink" id="btn-pink"
					href="http://wd.koudai.com/s/100569?wfr=c">
					<i class="icon-refresh bigger-230"></i>微商城
				</a>
			  	<a class="btn btn-app btn-purple"
					href="wumimember/memberaction!logout">
					<i class="icon-refresh bigger-230"></i>退出登陆
				</a>
		   </div>
		</div>
	  	<br />
	    <div style="height:50px;"></div>
        <div align="center" id="foot" style="height:50px;font-size:20px;">
	    	<a href="http://crm.wumi.me/ucenter/ucenter_registe.jsp"><b>我要使用</b></a>
	    </div>
	    <c:import url="/jsp/commons/footer.jsp"></c:import>
	</div>
	
	<!-- 弹出框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
   		aria-labelledby="myModalLabel" aria-hidden="true">
   		<div class="modal-dialog">
      		<div class="modal-content radius">
         		<div class="modal-header">
            		<button type="button" class="close" 
               			data-dismiss="modal" aria-hidden="true">
                  		&times;
            		</button>
            		<h4 class="modal-title" id="myModalLabel">
              			温馨提示
            		</h4>
         		</div>
         		<div class="modal-body">
         			<p>
         				<img alt="" src="${ctx }/assets/images/xiaohe_microshop_tip.png"
         					style="width: 289px; height: 170px;">
         			</p>
         		</div>
      		</div><!-- /.modal-content -->
    	</div><!-- /.modal -->
	</div>
	</body>
   
   <script type="text/javascript">
   		function showMyModal() {
   			$("#myModal").modal('show');
   			return false;
   		}
   		
   		$(document).ready(function() {
   			$(".thischange").text($("#bianzhifu").children().text()).css("font-weight","bold");
   			var theEaId = $("#bianzhifu").val();
   			$(".bianzhi").click(function(){
   				$(".thischange").text($(this).text());
   				var eaId = $(this).parent().val();
	   			var memberId = $("#memberId").val();
	   			theEaId = eaId;
	   			
	   			$("#btn-success")
   					.attr("href",
   						"wumimember/memberaction!initManager?member.id=" 
   						+ memberId + "&member.eaId=" 
   						+ eaId);
	   			$("#btn-warning")
	   				.attr("href",
	   						"wumimember/logscoreaction!watchLogScoreDetail?member.id=" 
	   						+ memberId + "&member.eaId=" 
	   						+ eaId);
	   			$("#btn-primary")
   					.attr("href",
   						"wumimember/logconsumeaction!watchLogConsumeDetail?member.id=" 
   						+ memberId + "&member.eaId=" 
   						+ eaId);
	   			
	   			$("#btn-danger")
   					.attr("href",
   						"wumimember/logbalanceaction!watchLogBalanceDetail?member.id=" 
   						+ memberId + "&member.eaId="
   						+ eaId);
	   			
	   			$.ajax({
					type: "POST",
					url:"wumimember/microshopaction!getMicroshopUrl",
					data:{"eaId": theEaId},
					dataType:"json",
					success: function(data) {
						var d = $.parseJSON(data);
						if (d != null) {
							if (d.temp != null) {
								$("#btn-pink").attr("href",d.temp);
								$("#btn-pink").removeAttr("onclick");
							}else if(d.xiaohe) {
								$("#btn-pink").attr("href","javascript:void(0);");
								$("#btn-pink").attr("onclick","showMyModal();");
							}
							
						}
					},
					error: function(request) {
			            alert("Connection error");
			      	}
	   			});
	   			
   			});
   			
   			$.ajax({
				type: "POST",
				url:"wumimember/microshopaction!getMicroshopUrl",
				data:{"eaId": theEaId},
				dataType:"json",
				success: function(data) {
					var d = $.parseJSON(data);
					if (d != null) {
						if (d.temp != null) {
							$("#btn-pink").attr("href",d.temp);
							$("#btn-pink").removeAttr("onclick");
						}else if(d.xiaohe) {
							$("#btn-pink").attr("href","javascript:void(0);");
							$("#btn-pink").attr("onclick","showMyModal();");
						}
						
					}
				},
				error: function(request) {
		            alert("Connection error");
		      	}
   			});
   		});
   </script>
</html>
